using System;
using System.IO;

namespace Caramel.IO
{
	public class WindowsFileInfo : IFileInfo
	{
		private FileInfo _fileInfo;

		public WindowsFileInfo(FileInfo fileInfo)
		{
			_fileInfo = fileInfo;
		}

		#region IFileInfo Members

		public StreamWriter AppendText()
		{
			return _fileInfo.AppendText();
		}

		public IFileInfo CopyTo(string destFileName, bool overwrite)
		{
			return
				new WindowsFileInfo(
					_fileInfo.
						CopyTo(
							destFileName, 
							overwrite
						)
				);
		}

		public Stream Create()
		{
			return _fileInfo.Create();
		}

		public StreamWriter CreateText()
		{
			return _fileInfo.CreateText();
		}

		public void Decrypt()
		{
			_fileInfo.Decrypt();
		}

		public void Encrypt()
		{
			_fileInfo.Encrypt();
		}

		public void MoveTo(string destFileName)
		{
			_fileInfo.MoveTo(destFileName);
		}

		public Stream Open(FileMode mode, FileAccess access, FileShare share)
		{
			return 
				_fileInfo.
					Open(
						mode, 
						access, 
						share
					);
		}

		public Stream OpenRead()
		{
			return _fileInfo.OpenRead();
		}

		public StreamReader OpenText()
		{
			return _fileInfo.OpenText();
		}

		public Stream OpenWrite()
		{
			return _fileInfo.OpenWrite();
		}

		public IFileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors)
		{
			return
				new WindowsFileInfo(
					_fileInfo.
						Replace(
							destinationFileName, 
							destinationBackupFileName, 
							ignoreMetadataErrors
						)
				);
		}

		public IDirectoryInfo Directory
		{
			get 
			{ 
				return new WindowsDirectoryInfo(_fileInfo.Directory); 
			}
		}

		public string DirectoryName
		{
			get
			{ 
				return _fileInfo.DirectoryName; 
			}
		}

		public bool IsReadOnly
		{
			get
			{
				return _fileInfo.IsReadOnly;
			}
			set
			{
				_fileInfo.IsReadOnly = value;
			}
		}

		public long Length
		{
			get 
			{ 
				return _fileInfo.Length;
			}
		}

		#endregion
	}
}
